import { useStore } from '@renderer/store/useStore'

export default () => {
  const setError = useStore((state) => state.setError)

  const registerShortcut = async () => {
    const config: ConfigType = await window.api.sql('SELECT * FROM config WHERE id = 1;', 'findOne')
    const shortcut = (JSON.parse(config.content) as ConfigContentType).shortcut
    const isBind = await window.api.shortcut(shortcut)
    isBind || setError('快捷键注册失败！')
  }
  return { registerShortcut }
}
